package org.spring.springboot.app.user.balancelog.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spring.springboot.app.user.balancelog.dao.SysUserBalanceLogDao;
import org.spring.springboot.app.user.balancelog.domain.po.SysUserBalanceLogPO;
import org.spring.springboot.app.user.balancelog.domain.vo.SysUserBalanceLogSearchVO;
import org.spring.springboot.app.user.balancelog.service.ISysUserBalanceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserBalanceLogServiceImpl implements ISysUserBalanceLogService {

    private static final Logger LOGGER = LoggerFactory.getLogger(SysUserBalanceLogServiceImpl.class);

    @Autowired
    private SysUserBalanceLogDao sysOfficeBalanceLogDao;


    @Override
    public SysUserBalanceLogPO find(String id) {
        return sysOfficeBalanceLogDao.selectByPrimaryKey(id);
    }

    @Override
    public List<SysUserBalanceLogPO> findPage(SysUserBalanceLogSearchVO searchvo, int pageNum, int pageSize, String types) {
        return sysOfficeBalanceLogDao.findPage(searchvo,pageNum,pageSize,types);
    }

    @Override
    public int save(SysUserBalanceLogPO po) {
        po.preInsert();
        return sysOfficeBalanceLogDao.insertSelective(po);
    }

    @Override
    public int update(SysUserBalanceLogPO po) {
        po.preUpdate();
        return sysOfficeBalanceLogDao.updateByPrimaryKeySelective(po);
    }

    @Override
    public int delete(String id) {
        SysUserBalanceLogPO po = new SysUserBalanceLogPO();
        po.setId(id);
        po.preDelete();
        return sysOfficeBalanceLogDao.updateByPrimaryKeySelective(po);
    }

    @Override
    public int deletes(String ids) {
        SysUserBalanceLogPO record = new SysUserBalanceLogPO();
        String[] id_s = ids.split(",");
        record.preDelete();
        int count = 0;
        for (String id : id_s) {
            record.setId(id);
            count += sysOfficeBalanceLogDao.updateByPrimaryKeySelective(record);
        }
        return count;
    }
}
